<?PHP
include "../../mainfile.php";
include XOOPS_ROOT_PATH.'/header.php';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>View Premiums</title>
<link rel="stylesheet" type="text/css" media="all" href="<?php echo xoops_getcss($xoopsConfig['theme_set']); ?>" />
<LINK href="pledge.css" rel="stylesheet" type="text/css">
</head>
<body style="background-color:#FFFFFF; ">
<?PHP

if($_GET['total'] == '0'){
	$_GET['action'] = 'all';
}

//echo $_GET['total'];
//echo "<P>".$_GET["ViewID0"];
if($_GET['action'] == 'view_selected'){
		$premiums = array();
		for($i=0; $i < $_GET['total']; ++$i){
			$result = $xoopsDB->query( "SELECT * FROM ".$xoopsDB->prefix("pledge_premiums")." WHERE ID = '".$_GET["ViewID$i"]."'" ) ;
			if($result){
				$myrow = $xoopsDB->fetchArray($result);
				$premiums[$i]['title'] = $myrow['title'];
				$premiums[$i]['image'] = $myrow['image'];
				$premiums[$i]['description'] = $myrow['description'];
				$premiums[$i]['pledge_level'] = $myrow['pledge_level'];
			}
		}
		


	//print_r($premiums);
}else{

		$premiums = array();
			$result = $xoopsDB->query( "SELECT * FROM ".$xoopsDB->prefix("pledge_premiums")) ;
			if ( $result ) {
				$x=0;
				while ( $myrow = $xoopsDB->fetchArray($result) ) {
					$premiums[$x]['title'] = $myrow['title'];
					$premiums[$x]['image'] = $myrow['image'];
					$premiums[$x]['description'] = $myrow['description'];
					$premiums[$x]['pledge_level'] = $myrow['pledge_level'];
					++$x;
				}//end while
			} 



}





 print "<table border='1' cellpadding='0' cellspacing='0' style=\"width:100%;\">\n
        <tr><th>Current Premiums</th></tr>\n
        <tr>\n
        <td>\n
		
		
            <table width='100%' border='0' cellpadding='2' cellspacing='1'>\n
			<tr nowrap='nowrap'>\n               
				<td class='head'>Title</td>
				<td class='head'>Image</td>
				<td class='head'>Description</td>
				<td class='head'>Pledge Level</td>
			</tr>";
			setlocale(LC_MONETARY, 'en_US');

			for($i=0; $i < count($premiums); ++$i){
				if($i&1){
					echo"<tr nowrap='nowrap' class=\"odd\">\n ";
				}else{
					echo"<tr nowrap='nowrap' class=\"even\">\n ";
				}
				
				echo"
				<td nowrap style=\"font-weight:bold; text-decoration:underline;\">".$premiums[$i]['title']."</td>
				<td width=\"120\"><img src=\"images/uploads/".$premiums[$i]['image']."\" border=\"1\"></td>
				<td >".$premiums[$i]['description']."</td>
				<td >".money_format('%.0n', $premiums[$i]['pledge_level'])."</td>
			</tr>";				
				
			
			}
			
			
			echo"
            </table>\n
        </td></tr>\n
    </table>\n";


//print_r($premiums);
?>

</body>
</html>